import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Dialogs 1.0
import QtQuick.XmlListModel 2.0
import QtQuick.Controls.Styles 1.0


Component {
    id: characterDelegate

    ListModel {
        id: characterFeaturesList
        ListElement { name: "Hit Die";          index: 0 }
        ListElement { name: "Skill Points";     index: 0 }
        ListElement { name: "Base Attack";      index: 0 }
        ListElement { name: "Fortitude Save";   index: 0 }
        ListElement { name: "Reflex Save";      index: 0 }
        ListElement { name: "Willpower Save";   index: 0 }
    }

    Button {
        id: characterButton
        text: name
        anchors.left: parent.left
        anchors.right: parent.right
        
        function setEnabled()
        {
            enabled = true;
        }
        
        onClicked: {
            var component = Qt.createComponent("CharacterDialog.qml");
            if (component.status == Component.Ready)
            {
                var object = component.createObject();
                if (!object)
                {
                    return;
                }
                object.title = text;
                object.visible = true;
                object.model = characterFeaturesList;
                object.closing.connect(setEnabled);
                enabled = false;
            }
        }
        
    }
}
